from django.db import models
from img_db.models import IMG
# Create your models here.
class UserMsg(models.Model):
    '''
    创建用户信息表
    '''
    name=models.CharField(max_length=50)
    passwd=models.CharField(max_length=50)
    email=models.EmailField()
    phone=models.CharField(max_length=50)
    isadmin=models.BooleanField(default=False)

class ArticleType(models.Model):
    '''
    articletype信息表
    '''
    articletype=models.CharField(max_length=30)
    def __str__(self):
        return self.articletype
class Article(models.Model):
    aid=models.AutoField(primary_key=True)
    title=models.CharField(max_length=100,null=False) #标题
    author_name = models.CharField(max_length=100, null=False)
    abstract = models.TextField()  # 摘要
    content=models.TextField(null=False)
    type=models.ForeignKey(ArticleType,on_delete=models.CASCADE)

class Comment(models.Model):
    '''
    comment表
    '''
    article_id=models.ForeignKey(Article,on_delete=models.CASCADE)
    content=models.TextField()

    def __str__(self):
        return self.article_id